﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LS_JZCSWebForm.aspx.cs" Inherits="Anke.SHManage.Web.Reports.LS_JZCSWebForm" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>救治措施流水表</title>
    <script src="../Content/EasyUI/jquery.js"></script>
    <script src="../Content/EasyUI/jquery.easyui.js"></script>
    <script src="../Content/EasyUI/locale/easyui-lang-zh_CN.js"></script>
    <link href="../Content/EasyUI/themes/icon.css" rel="stylesheet" />
    <link href="../Content/EasyUI/themes/default/easyui.css" rel="stylesheet" />
    <script src="../Scripts/jquery.AnkeExtend.js"></script>
    <script type="text/javascript">
        //页面加载
        $(document).ready(function () {
            DisableBackspace();
            reload();
        });
        function fillCombobox() {

            //取所属分中心的下拉框的值
            $("#Center").combobox({
                url: "../BB/AllDictionary/GetCenterName",
                valueField: 'ID',
                textField: 'Name',
                editable: false,
                multiple: true,
                prompt: '--请选择--',
                onSelect: function (rec) {
                    var ids = $('#Center').combobox('getValues');
                    //根据分中心取分站
                    $("#Station").combobox({
                        url: "../BB/AllDictionary/GetSationName?centerID=" + ids,
                        method: 'POST',
                        valueField: 'ID',
                        textField: 'Name',
                        multiple: true,
                        editable: false,
                        onSelect: function () {
                            $('#Station').combobox('getValues')
                        },
                        onUnselect: function () {
                            $('#Station').combobox('getValues')
                        }
                    });
                    $("#Station").combobox('clear');
                },
                onUnselect: function (rec) {
                    var ids = $('#Center').combobox('getValues');
                    //根据分中心取分站
                    $("#Station").combobox({
                        url: "../BB/AllDictionary/GetSationName?centerID=" + ids,
                        method: 'POST',
                        valueField: 'ID',
                        textField: 'Name',
                        multiple: true,
                        editable: false
                        //onSelect: function () {
                        //    //$('#Station').combobox('getValues')
                        //},
                        //onUnselect: function () {
                        //    $('#Station').combobox('getValues')
                        //}
                    });
                    // $("#Station").combobox('setValues', '');
                    $("#Station").combobox('clear');
                },
            });

            var centers = $('#Center').combobox('getValues');
            $("#Station").combobox({
                url: "../BB/AllDictionary/GetSationName?centerID=" + centers,
                method: 'POST',
                valueField: 'ID',
                textField: 'Name',
                multiple: true,
                editable: false,
                onSelect: function () {
                    $('#Station').combobox('getValues')
                },
                onUnselect: function () {
                    $('#Station').combobox('getValues')
                }
            });
        }

        function initSearch() {

            var urlstr = "../IM/AllDictionary/GetMeasureType";
            $.EUIcomboboxTree("#MeasureType", {
                url: urlstr,//ajax后台取数据路径，返回的是json格式的数据
                OneOption: [{
                    id: "",
                    text: "--请选择--",
                }],
                datainfo: {},
                onSelect: function (rec) {
                    if (rec.id == "") {
                        $("#MeasureID").val("");
                        $("#MeasureTypeInfo").val("");
                        return;
                    }
                    var urlstr3 = "../IM/AllDictionary/GetMeasure?measureType=" + rec.id;
                    $("#MeasureTypeInfo").val(rec.id);
                    $("#Measure").combogrid({
                        prompt: '--请选择--',
                        panelWidth: 320,
                        idField: 'ID',
                        multiple: true,
                        textField: 'Name',
                        groupField: 'QRCode',
                        columns: [[
                            { field: 'Name', title: '名称', width: 100 },
                            { field: 'UnitName', title: '单位', width: 50 },
                            { field: 'RealPrice', title: '售价', width: 50 },
                            { field: 'Unit', title: '单位', width: 50, sortable: false, hidden: true }
                        ]],
                        fitColumns: true,
                        filter: function (inputText, row) {
                            var opts = $(this).combogrid('options');
                            if (row[opts.groupField] == inputText) {
                                return true;
                            } else if (row[opts.textField] == inputText) {
                                return true;
                            } else {
                                if (boolSearch) {
                                    boolSearch = false;
                                    searchBindMeterialbyName(urlstr3, inputText);
                                }
                            }
                        },
                        onChange: function (n, o) {
                            if (n == "") {
                                searchBindMeterialbyName(urlstr3, n);
                                $("#MeasureID").val("");
                            }
                        },
                        onSelect: function (rec) {
                            var g = $("#Measure").combogrid("grid");	// 获取数据表格对象
                            var r = g.datagrid('getSelected');	// 获取选择的行
                            $("#MeasureID").val($('#Measure').combobox('getValue'));
                        }
                    });
                    searchBindMeterialbyName(urlstr3, "");
                }
            });

            var urlstr5 = "../IM/AllDictionary/GetMeasureList";
            $("#Measure").combogrid({
                prompt: '--请选择--',
                panelWidth: 320,
                idField: 'ID',
                textField: 'Name',
                groupField: 'QRCode',
                columns: [[
                    { field: 'Name', title: '名称', width: 100 },
                    { field: 'UnitName', title: '单位', width: 50 },
                    { field: 'RealPrice', title: '售价', width: 50 },
                    { field: 'Unit', title: '单位', width: 50, sortable: false, hidden: true }
                ]],
                fitColumns: true,
                filter: function (inputText, row) {
                    var opts = $(this).combogrid('options');
                    if (row[opts.groupField] == inputText) {
                        return true;
                    } else if (row[opts.textField] == inputText) {
                        return true;
                    } else {
                        if (boolSearch) {
                            boolSearch = false;
                            searchBindMeterialbyName(urlstr5, inputText);
                        }
                    }
                },
                onChange: function (n, o) {
                    if (n == "") {
                        searchBindMeterialbyName(urlstr5, n);
                        $("#MeasureID").val("");
                    }
                },
                onSelect: function (rec) {
                    var g = $("#Measure").combogrid("grid");	// 获取数据表格对象
                    var r = g.datagrid('getSelected');	// 获取选择的行
                    $("#MeasureID").val($('#Measure').combobox('getValue'));
                }
            });
            searchBindMeterialbyName(urlstr5, "");
        }
        function searchBindMeterialbyName(urinfo, keyWord) {
            $.ajax({
                type: 'POST',
                url: urinfo,
                dataType: "json",
                success: function (jsData) {
                    if (keyWord == "") {
                        $("#Measure").combogrid("grid").datagrid("loadData", jsData);
                    } else {
                        for (var i = 0; i < jsData.length; i++) {
                            if (jsData[i].Name.indexOf(keyWord) < 0) {
                                //if (jsData[i].MCode.indexOf(keyWord) < 0) {
                                // if (jsData[i].PinYin.indexOf(keyWord) < 0) {
                                jsData.remove(jsData[i]);
                                i--;
                                //}
                                //}
                            }
                        }
                        $("#Measure").combogrid("grid").datagrid("loadData", jsData);
                    }
                    boolSearch = true;
                }
            });
        }







        // 实现UpdatePanel中可以再添加easyUI的样式
        function reload() {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        }
        function EndRequestHandler() {
            fillCombobox();
            initSearch();
            $('#StartDate').datetimebox();
            $('#EndDate').datetimebox();
            $('#txtAgentWorkID').textbox();
            $('#txtDoctorAndNurse').textbox();
            $('#MeasureType').combobox();
            $('#Measure').combogrid();



        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <table>
                    <tr>

                        <td>查询时间：</td>
                        <td>
                            <asp:TextBox ID="StartDate" class="easyui-datetimebox" Style="width: 150px" runat="server" editable="false"></asp:TextBox>
                        </td>
                        <td style="text-align: center">至</td>
                        <td>
                            <asp:TextBox ID="EndDate" class="easyui-datetimebox" Style="width: 150px" runat="server" editable="false"></asp:TextBox>
                        </td>
                        <td>救治措施大类：</td>
                        <td>
                            <asp:TextBox ID="MeasureType" class="easyui-combobox" Style="width: 150px" runat="server" editable="false"></asp:TextBox>
                            <asp:TextBox ID="MeasureTypeInfo" type="hidden" runat="server"></asp:TextBox>

                        </td>
                        <td>救治措施详细:</td>
                        <td>
                            <asp:TextBox ID="Measure" class="easyui-combogrid" Style="width: 150px" runat="server" editable="false"></asp:TextBox>
                            <asp:TextBox ID="MeasureID" type="hidden" runat="server"></asp:TextBox>
                        </td>

                    </tr>
                    <tr>
                        <td>工号：</td>
                        <td>
                            <asp:TextBox ID="txtAgentWorkID" class="easyui-textbox" Style="width: 150px" runat="server"></asp:TextBox>
                        </td>

                        <td>急救医护人：</td>
                        <td>
                            <asp:TextBox ID="txtDoctorAndNurse" class="easyui-textbox" Style="width: 150px" runat="server"></asp:TextBox>
                        </td>


                        <td style="text-align: right">分中心：</td>
                        <td>
                            <asp:TextBox ID="Center" class="easyui-combobox" Style="width: 150px" runat="server"></asp:TextBox>
                            <%--<asp:DropDownList ID="DropDownList_Center" runat="server" Width="150px" AutoPostBack="True" OnSelectedIndexChanged="DropDownList_Center_SelectedIndexChanged"></asp:DropDownList>--%>
                        </td>
                        <td style="text-align: right">分站：</td>
                        <td>
                            <asp:TextBox ID="Station" class="easyui-combobox" Style="width: 150px" runat="server"></asp:TextBox>
                            <%--<asp:DropDownList ID="DropDownList_Station" runat="server" Width="150px" AutoPostBack="True"></asp:DropDownList>--%>
                        </td>
                        <td>
                            <asp:Button ID="Button1" runat="server" Text="查询" OnClick="btnSearch_Click" />
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
        <div style="background-color: #fafafa; border-left: 1px solid scrollbar; overflow: hidden; height: 100%;">
            <rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="100%" Height="100%"
                ZoomMode="PageWidth" ShowBackButton="true" SizeToReportContent="True">
            </rsweb:ReportViewer>
        </div>
    </form>
</body>
</html>
